package com.cx.service.impl;

import com.cx.mapper.EngineMapper;
import com.cx.pojo.Engine;
import com.cx.service.EngineService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EngineServiceImpl implements EngineService {

    @Autowired
    EngineMapper engineMapper;

    @Override
    public int insert(Engine engine) {
        return engineMapper.insert(engine);
    }

    @Override
    public int updateByPrimaryKey(Engine engine) {
        return engineMapper.updateByPrimaryKey(engine);
    }

    @Override
    public int deleteByPrimaryKey(Integer eId) {
        return engineMapper.deleteByPrimaryKey(eId);
    }

    @Override
    public Engine selectByPrimaryKey(Integer eId) {
        return engineMapper.selectByPrimaryKey(eId);
    }

    //分页
    public PageInfo<Engine> selectAllEngine(Engine engine) {
        PageHelper.startPage(engine.getPageNum(), engine.getPageSize());
        List<Engine> engineList = engineMapper.selectAllEngine(engine);
        return new PageInfo<>(engineList);
    }
}
